package chapter05

object Demo01_FunctionAndMethod {
  def main(args: Array[String]): Unit = {

    def sayHi(name: String): Unit = {
      println("hi " + name)
    }
    //调用函数
    sayHi("alice")

    //调用对象方法
    Demo01_FunctionAndMethod.sayHi("Bob")

    //获取方法返回值
    val result = Demo01_FunctionAndMethod.sayHello("cary")
    println(result)
  }

  //定义对象的方法
  def sayHi(name: String): Unit = {
    println("Hi " + name)
  }

  def sayHello(name: String): String = {
    println("Hello " + name)
    return "Hello"
  }
}
